package hsb.ruoyi.admin.web.controller.monitor;

import hsb.ruoyi.common.annotation.Log;
import hsb.ruoyi.common.core.controller.BaseController;
import hsb.ruoyi.common.core.domain.AjaxResult;
import hsb.ruoyi.common.core.page.TableDataInfo;
import hsb.ruoyi.common.enums.BusinessType;
import hsb.ruoyi.system.domain.SysOperLog;
import hsb.ruoyi.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * 操作日志记录
 *
 * @author ruoyi
 */
@Produces(MediaType.APPLICATION_JSON)
@Path("/monitor/operlog")
public class SysOperlogController extends BaseController {
    @Autowired
    private ISysOperLogService operLogService;

    //@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
    @GET
    @Path("/list")
    public TableDataInfo list(@BeanParam SysOperLog operLog) {
        startPage();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }

//    //@Log(title = "操作日志", businessType = BusinessType.EXPORT)
//    //@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
//    @POST @Path("/export")
//    public void export(HttpServletResponse response, SysOperLog operLog)
//    {
//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
//        util.exportExcel(response, list, "操作日志");
//    }

    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    //@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
    @DELETE
    @Path("/{operIds}")
    public AjaxResult remove(@PathParam("operIds") Long[] operIds) {
        return toAjax(operLogService.deleteOperLogByIds(operIds));
    }

    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    //@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
    @DELETE
    @Path("/clean")
    public AjaxResult clean() {
        operLogService.cleanOperLog();
        return AjaxResult.success();
    }
}
